package com.xcity.pomelo.response;

import com.xcity.db.entity.Guild;
import com.xcity.db.entity.GuildMember;
import com.xcity.db.entity.Player;
import com.xcity.game.guild.GuildService;
import com.xcity.game.player.cache.PlayerCacheService;
import com.xcity.pomelo.response.GuildListResponse.GuildInfo;

import naga.x.App;
import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class GuildDetailResponse extends Response {

	private GuildDetail detail;
	private int duty;
	
	public static class GuildDetail extends GuildInfo{
		public int curExp;
		public int maxExp;
		public String chairmanName;
		public int joinType;
		public int joinLvl;
		public String slogan;
		public GuildDetail(Guild guild, int lvl, int showCur, int showNeed) {
			super(guild, lvl);
			this.curExp = showCur;
			this.maxExp = showNeed;
			Player chairman = App.getApp().getServiceManager().get(PlayerCacheService.class).find(guild.getChairmanId());
			if(chairman != null){
				this.chairmanName = chairman.getName();
			}
			this.joinType = guild.getJoinType();
			this.joinLvl = guild.getJoinLvl();
			this.slogan = guild.getSlogan();
		}
	}
	
	public GuildDetailResponse(int serial, Guild guild, int lvl, int showCur, int showNeed, GuildMember member) {
		super(serial);
		detail = new GuildDetail(guild, lvl, showCur, showNeed);
		duty = GuildService.getClientDuty(member.getDuty());
	}
	public GuildDetail getDetail() {
		return detail;
	}

	public void setDetail(GuildDetail detail) {
		this.detail = detail;
	}
	public int getDuty() {
		return duty;
	}
	public void setDuty(int duty) {
		this.duty = duty;
	}
}
